#ifndef STD_DEFS
#define STD_DEFS

/*  Copyright (c) by Medtronic, Inc., 2003.  */
/*  $Source: /cvs/repository/bwell/firmware/code/inc/STD_DEFS.H,v $  */
/*  $Revision: 71 $  */
/*  $Date: 2013-08-12 13:43:22 +0000 (Mon, 12 Aug 2013) $  */

/**********************************************************************
 *
 * Copyright (c) Medtronic, Inc. 2003
 *
 * File:        std_defs.h
 *
 * Description:
 *
 * All of the standard definitions and data type definitions are found
 * in this file
 *
 **********************************************************************/
#ifdef CREATE_MEM
#define DECLARE
#else
#define DECLARE extern
#endif

#include <stdint.h>
#include <stdbool.h>
#include "pack.h"  

#define  FALSE  ((bool)(0))
#define  TRUE   ((bool)(1))
#define  BAD    0
#define  GOOD   1
#define  FAIL   0
#define  PASS   1
#define  OFF    0
#define  ON     1

// Function pointers:
typedef void (*PFUNC)(void);
typedef void (*PFUNC_UINT32P)( uint32_t *);

#ifndef NULL
#define NULL 0
#endif

#define NULL_FUNC_PTR  (void (*)(void))0

#define max( x, y ) (( ((x) > (y)) ? (x) : (y) ) /* parasoft-suppress CODSTA-06 "The ? operator is more readable in a macro" */)
#define min( x, y ) (( ((x) < (y)) ? (x) : (y) ) /* parasoft-suppress CODSTA-06 "The ? operator is more readable in a macro" */)

typedef void (*transition_handler_t)(void);

#define MS /10

typedef struct
{
    uint8_t byte_hi;
    union
    {
        uint16_t word; /* low 16 bits of pointer*/
        struct
        {
            uint8_t mid;
            uint8_t low;
        } byte;
    } lower16 __attribute__((packed));

} THREE_BYTE_P;

typedef union
{
    uint16_t whole;
    struct
    {
        unsigned char lsb;
        unsigned char msb;
    } byte;
} SPLIT_INT_TYPE;

typedef union ///< @FDS_STRUCT: INTEGER_UNION_TYPE - structure - Defines a generic 16 bit counter/value.
{
    __packed uint16_t whole; ///< @FDS: This value contains the full 16-bits of the value.
    struct ///< @FDS_STRUCT: half - structure - Contains the individual low and high bytes of the value.
    {
		uint8_t low_byte;    ///< @FDS: This value contains the low 8 bits of the 16 bit value.
        uint8_t high_byte; ///< @FDS: This value contains the high 8 bits of the 16 bit value.
    } half; ///< @FDS_STRUCT_END
} INTEGER_UNION_TYPE; ///< @FDS_STRUCT_END

#endif

